<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="110px"
    >
      <el-form-item label="任务编号" prop="taskCode">
        <el-input
          v-model="queryParams.taskCode"
          placeholder="请输入任务编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="任务标题" prop="taskTitle">
        <el-input
          v-model="queryParams.taskTitle"
          placeholder="请输入任务标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="任务类型" prop="taskType">
        <el-select
          v-model="queryParams.taskType"
          placeholder="请选择任务类型"
          clearable
        >
          <el-option
            v-for="dict in dict.type.task_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="任务优先级" prop="priority">
        <el-input
          v-model="queryParams.priority"
          placeholder="请输入任务优先级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="创建人" prop="creatorId">
        <el-input
          v-model="queryParams.creatorId"
          placeholder="请输入创建人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="创建人姓名" prop="creatorName">
        <el-input
          v-model="queryParams.creatorName"
          placeholder="请输入创建人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="被分配人" prop="assigneeId">
        <el-input
          v-model="queryParams.assigneeId"
          placeholder="请输入被分配人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="被分配人姓名" prop="assigneeName">
        <el-input
          v-model="queryParams.assigneeName"
          placeholder="请输入被分配人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="包区" prop="deptId">
        <!-- <el-input
          v-model="queryParams.deptId"
          placeholder="请输入包区"
          clearable
          @keyup.enter.native="handleQuery"
        /> -->
        <el-cascader
          v-model="queryParams.deptId"
          :options="deptOptions"
          @change="handleChange"
          placeholder="请选择所属包区"
        >
        </el-cascader>
      </el-form-item>
      <el-form-item label="任务状态" prop="taskStatus">
        <el-select
          v-model="queryParams.taskStatus"
          placeholder="请选择任务状态"
          clearable
        >
          <el-option
            v-for="dict in dict.type.task_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="分配时间" prop="assignedAt">
        <el-date-picker
          clearable
          v-model="queryParams.assignedAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择分配时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="开始处理时间" prop="startedAt">
        <el-date-picker
          clearable
          v-model="queryParams.startedAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择开始处理时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="完成时间" prop="completedAt">
        <el-date-picker
          clearable
          v-model="queryParams.completedAt"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择完成时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:tracking:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:tracking:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:tracking:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:tracking:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="trackingList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="${comment}"
        align="center"
        prop="id"
        v-if="columns[0].visible"
      />
      <el-table-column label="任务编号" align="center" prop="taskCode" />
      <el-table-column label="任务标题" align="center" prop="taskTitle" />
      <el-table-column label="任务描述" align="center" prop="taskDescription" />
      <!-- <el-table-column label="问题附件URL" align="center" prop="questionUrl" /> -->
      <el-table-column label="任务类型" align="center" prop="taskType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.task_type"
            :value="scope.row.taskType"
          />
        </template>
      </el-table-column>
      <el-table-column label="任务优先级" align="center" prop="priority">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.task_priority"
            :value="scope.row.priority"
          />
        </template>
      </el-table-column>
      <!-- <el-table-column label="创建人" align="center" prop="creatorId" /> -->
      <el-table-column label="创建人姓名" align="center" prop="creatorName" />
      <!-- <el-table-column label="被分配人" align="center" prop="assigneeId" /> -->
      <el-table-column label="被分配人姓名" align="center" prop="assigneeName">
        <!-- <template slot-scope="scope">
          {{ getUserName(scope.row.assigneeName) }}
        </template> -->
      </el-table-column>
      <el-table-column label="包区" align="center" prop="deptId">
        <template slot-scope="scope">
          {{ getDeptName(scope.row.deptId) }}
        </template>
      </el-table-column>

      <el-table-column label="任务状态" align="center" prop="taskStatus">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.task_status"
            :value="scope.row.taskStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="分配时间"
        align="center"
        prop="assignedAt"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.assignedAt, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="开始处理时间"
        align="center"
        prop="startedAt"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startedAt, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="完成时间"
        align="center"
        prop="completedAt"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.completedAt, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="处理结果描述"
        align="center"
        prop="resultDescription"
      />
      <!-- <el-table-column label="附件URL" align="center" prop="attachmentUrls" /> -->
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="150"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:tracking:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:tracking:remove']"
            >删除</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            v-hasPermi="['system:tracking:query']"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改task对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="任务编号" prop="taskCode">
              <el-input v-model="form.taskCode" placeholder="请输入任务编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务标题" prop="taskTitle">
              <el-input v-model="form.taskTitle" placeholder="请输入任务标题" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="任务描述" prop="taskDescription">
              <el-input
                v-model="form.taskDescription"
                type="textarea"
                placeholder="请输入内容"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="问题附件URL" prop="questionUrl">
              <!-- <el-input
                v-model="form.questionUrl"
                type="textarea"
                placeholder="请输入内容"
              /> -->
              <file-upload v-model="form.questionUrl" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务类型" prop="taskType">
              <el-select v-model="form.taskType" placeholder="请选择任务类型">
                <el-option
                  v-for="dict in dict.type.task_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务优先级" prop="priority">
              <el-input
                v-model="form.priority"
                placeholder="请输入任务优先级"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="创建人" prop="creatorId">
              <el-input v-model="form.creatorId" placeholder="请输入创建人" />
            </el-form-item>
          </el-col> -->
          <input type="hidden" v-model="form.creatorId" />
          <el-col :span="12">
            <el-form-item label="创建人姓名" prop="creatorName">
              <el-input
                readonly="true"
                v-model="nickName"
                placeholder="请输入创建人姓名"
              />

              <!-- <el-select
                v-model="form.creatorName"
                placeholder="请选择创建人姓名"
                clearable
              >
                <el-option
                  v-for="item in userList"
                  :key="item.userId"
                  :label="item.nickName"
                  :value="item.nickName"
                  @change="changeCreatorName"
                />
              </el-select> -->
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="被分配人" prop="assigneeId">
              <el-input
                v-model="form.assigneeId"
                placeholder="请输入被分配人"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="被分配人包区" prop="deptId">
              <!-- <el-input v-model="form.deptId" placeholder="请输入包区" /> -->
              <el-cascader
                v-model="form.deptId"
                :options="deptOptions"
                @change="handleChange"
                placeholder="请选择被分配人包区"
              >
              </el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="被分配人姓名" prop="assigneeName">
              <!-- <el-input
                v-model="form.assigneeName"
                placeholder="请输入被分配人姓名"
              /> -->
              <el-select
                v-model="form.assigneeName"
                placeholder="请选择创建人姓名"
                clearable
                @change="changeAssigneeName"
              >
                <el-option
                  v-for="item in userList"
                  :key="item.userId"
                  :label="item.nickName"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
          </el-col>
          
          <el-col :span="12">
            <el-form-item label="任务状态" prop="taskStatus">
              <el-select v-model="form.taskStatus" placeholder="请选择任务状态">
                <el-option
                  v-for="dict in dict.type.task_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分配时间" prop="assignedAt">
              <el-date-picker
                clearable
                v-model="form.assignedAt"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择分配时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始处理时间" prop="startedAt">
              <el-date-picker
                clearable
                v-model="form.startedAt"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择开始处理时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完成时间" prop="completedAt">
              <el-date-picker
                clearable
                v-model="form.completedAt"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择完成时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="处理结果描述" prop="resultDescription">
              <el-input
                v-model="form.resultDescription"
                type="textarea"
                placeholder="请输入内容"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="附件URL" prop="attachmentUrls">
              <!-- <el-input
                v-model="form.attachmentUrls"
                type="textarea"
                placeholder="请输入内容"
              /> -->
              <file-upload v-model="form.attachmentUrls" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model="form.remark"
                type="textarea"
                placeholder="请输入内容"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--task详情 -->

    <el-dialog
      title="任务分发详情"
      :visible.sync="openDetail"
      width="800px"
      append-to-body
    >
      <el-form ref="form" :model="form" label-width="120px" size="mini">
        <el-row>
          <el-col :span="12">
            <el-form-item label="任务编号：">
              {{ form.taskCode }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务标题：">
              {{ form.taskTitle }}
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="任务描述：">
              {{ form.taskDescription }}
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="问题附件URL：">
              <a
                :href="baseUrl + form.questionUrl"
                target="_blank"
                class="buttonText"
                >下载附件</a
              >
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务类型：">
              <dict-tag
                :options="dict.type.task_type"
                :value="form.taskType"
              ></dict-tag>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务优先级：">
              <!-- {{ form.priority }} -->
              <dict-tag
                :options="dict.type.task_priority"
                :value="form.priority"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="创建人：">
              {{ form.creatorId }}
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="创建人姓名：">
              {{ form.creatorName }}
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="被分配人：">
              {{ form.assigneeId }}
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="被分配人姓名：">
              {{ form.assigneeName }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包区：">
              {{getDeptName(form.deptId)}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务状态：">
              <dict-tag
                :options="dict.type.task_status"
                :value="form.taskStatus"
              ></dict-tag>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分配时间：">
              {{ parseTime(form.assignedAt, "{y}-{m}-{d}") }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始处理时间：">
              {{ parseTime(form.startedAt, "{y}-{m}-{d}") }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完成时间：">
              {{ parseTime(form.completedAt, "{y}-{m}-{d}") }}
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="处理结果描述：">
              {{ form.resultDescription }}
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="附件URL：">
              <!-- {{ form.attachmentUrls }} -->
              <template>
                <a
                  :href="baseUrl + form.attachmentUrls"
                  target="_blank"
                  class="buttonText"
                  >下载附件</a
                >
              </template></el-form-item
            ></el-col
          ></el-row
        ></el-form
      ></el-dialog
    >
  </div>
</template>
            

<script>
import {
  listTracking,
  getTracking,
  delTracking,
  addTracking,
  updateTracking,
} from "@/api/system/tracking";
import { listDept } from "@/api/system/dept";
import { listUser, getDeptTree } from "@/api/system/user";
import store from "@/store";
export default {
  name: "Tracking",
  dicts: ["task_status", "task_type", "task_priority"],
  data() {
    return {
      userId: store.state.user.id, //将缓存的用户id赋值给userId，用于查询营销人员
      userName: store.state.user.name, //将缓存的用户id赋值给userId，用于查询营销人员
      nickName: store.state.user.nickName, //将缓存的用户id赋值给userId，用于查询营销人员
      deptId: store.state.user.deptId, //将缓存的用户id赋值给userId，用于查询营销人员
      userList: [],
      baseUrl: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      //包区选项
      deptOptions: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // task表格数据
      trackingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      openDetail: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        taskCode: null,
        taskTitle: null,
        taskDescription: null,
        questionUrl: null,
        taskType: null,
        priority: null,
        creatorId: null,
        creatorName: null,
        assigneeId: null,
        assigneeName: null,
        deptId: null,
        taskStatus: null,
        assignedAt: null,
        startedAt: null,
        completedAt: null,
        resultDescription: null,
        attachmentUrls: null,
      },
      columns: [
        { key: 0, label: "${comment}", visible: false },
        { key: 1, label: "任务编号", visible: false },
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        taskCode: [
          { required: true, message: "任务编号不能为空", trigger: "blur" },
        ],
        taskTitle: [
          { required: true, message: "任务标题不能为空", trigger: "blur" },
        ],
        creatorId: [
          { required: true, message: "创建人不能为空", trigger: "blur" },
        ],
        creatorName: [
          { required: true, message: "创建人姓名不能为空", trigger: "blur" },
        ],
        assigneeId: [
          { required: true, message: "被分配人不能为空", trigger: "blur" },
        ],
        deptId: [
          { required: true, message: "包区不能为空", trigger: "blur" },
        ],
        assigneeName: [
          { required: true, message: "被分配人姓名不能为空", trigger: "blur" },
        ],
        taskStatus: [
          { required: true, message: "任务状态不能为空", trigger: "change" },
        ],
        assignedAt: [
          { required: true, message: "分配时间不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
    this.getDeptList();
    this.getDeptTree(100);
    
  },
  methods: {
    changeAssigneeName(value) {
      console.log(value);
      console.log("#########选择任务被分配人########");
      this.form.assigneeId = value;
      this.form.assigneeName = this.getUserName(value);
    },
    // 获取用户列表
    getUserList(queryParams) {
      listUser(queryParams).then((response) => {
        console.log(response.rows); // 打印用户列表数据
        this.userList = response.rows; // 打印用户列表数据
        console.log(this.userList); // 打印用户列表数据

        console.log("#################");
      });
    },
    handleChange(value) {
      console.log(value[1]);
      this.form.deptId = value[1];
      let queryParams={
        pageNum: 1,
        pageSize: 10,
        deptId: value[1],
      }
      this.getUserList(queryParams);
    },
    // 获取用户姓名
    getUserName(userId) {
      return this.userList.find((item) => item.userId == userId)?.nickName;
    },
    getDeptName(deptId) {},
    /** 查询部门下拉树结构 */
    async getDeptTree(deptId) {
      getDeptTree({ deptId: deptId }).then((response) => {
        if (deptId == 100) {
          var treeData = response.data.children;
          treeData.map((item) => {
            item.label = item.deptName;
            item.value = item.deptId;
            if (item.children && item.children.length) {
              item.children.forEach((child) => {
                child.label = child.deptName;
                child.value = child.deptId;
                delete child.children;
              });
            }
          });
          this.deptOptions = treeData;
        }
      });
    },
    getDeptList() {
      listDept().then((response) => {
        this.deptList = response.data;
        this.deptList = this.filterDisabledDept(this.deptList);
      });
    },

    // 过滤禁用的部门
    filterDisabledDept(deptList) {
      return deptList.filter((dept) => {
        if (dept.disabled) {
          return false;
        }
        if (dept.children && dept.children.length) {
          dept.children = this.filterDisabledDept(dept.children);
        }
        return true;
      });
    },
    getDeptName(deptId) {
      return this.deptList.find((item) => item.deptId == deptId)?.deptName;
    },
    /** 查询task列表 */
    getList() {
      this.loading = true;
      listTracking(this.queryParams).then((response) => {
        this.trackingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        taskCode: null,
        taskTitle: null,
        taskDescription: null,
        questionUrl: null,
        taskType: null,
        priority: null,
        creatorId: store.state.user.id,
        creatorName: store.state.user.nickName,
        assigneeId: null,
        assigneeName: null,
        deptId: null,
        taskStatus: null,
        assignedAt: null,
        startedAt: null,
        completedAt: null,
        resultDescription: null,
        attachmentUrls: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加task";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      let queryParams={
        deptId: row.deptId,
      }
      this.getUserList(queryParams);
      getTracking(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改task";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateTracking(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTracking(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 详细按钮操作 */
    handleView(row) {
      this.openDetail = true;
      this.form = row;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除task编号为"' + ids + '"的数据项？')
        .then(function () {
          return delTracking(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/tracking/export",
        {
          ...this.queryParams,
        },
        `tracking_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style scoped lang="scss">
.buttonText {
  color: #1890ff;
}
</style>
